package com.organize.configure;

import com.organize.application.services.DepartmentAppService;
import com.organize.application.services.EmployeeAppService;
import com.organize.context.OrganizeComponentWebApiCondition;
import com.organize.controllers.DepartmentController;
import com.organize.controllers.EmployeeController;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-10-17 17:34
 **/
@Configuration
@Conditional(OrganizeComponentWebApiCondition.class)
public class OrganizeWebApiConfiguration {

    /**
     * 部门 Web Api
     *
     * @param service 服务
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(DepartmentController.class)
    public DepartmentController departmentController(DepartmentAppService service) {
        return new DepartmentController(service);
    }

    /**
     * 职员 Web Api
     *
     * @param service 服务
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(EmployeeController.class)
    public EmployeeController employeeController(EmployeeAppService service) {
        return new EmployeeController(service);
    }
}
